package com.example.neteasemusic.fragments

import android.util.Log
import android.view.LayoutInflater
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import com.example.lib_data.base.fragment.BaseFragment
import com.example.lib_data.bmob.MusicManager
import com.example.neteasemusic.MainActivity
import com.example.neteasemusic.R
import com.example.neteasemusic.adapter.MusicAdapter
import com.example.neteasemusic.databinding.FragmentHomeBinding

class HomeFragment:BaseFragment() {
    private val binding:FragmentHomeBinding by lazy {
        mBinding as FragmentHomeBinding
    }
    override fun getLayoutBinding(inflater: LayoutInflater): ViewBinding? {
        return FragmentHomeBinding.inflate(inflater)
    }

    override fun initData() {
        val adapter = MusicAdapter()
        binding.recyclerView.layoutManager = LinearLayoutManager(requireContext(),RecyclerView.VERTICAL,false)
        binding.recyclerView.adapter = adapter
        MusicManager.instance.loadMusics(
            onStart = {},
            callBack = {
                adapter.setMusics(it)
            }
        )
        //请求PostNotification权限
        (requireActivity() as MainActivity).requestPostNotification()
    }
}